Hanye官网
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

[id].vue 42KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389
  1. <template>
  2. <div>
  3. <div class="w-full h-[55px] sm:h-[72px]"></div>
  4. <ErrorBoundary :error="error">
  5. <div v-if="isLoading" class="flex justify-center py-12">
  6. <!-- 加载中 -->
  7. <div
  8. class="animate-spin h-8 w-8 border-4 border-cyan-400 rounded-full border-t-transparent"
  9. ></div>
  10. </div>
  11. <div v-else>
  12. <!-- 面包屑导航 -->
  13. <div class="max-w-full mb-6 xl:px-2 lg:px-2 md:px-4 px-4 mt-6">
  14. <div class="max-w-screen-2xl mx-auto">
  15. <nuxt-link
  16. :to="`${homepagePath}/`"
  17. class="justify-start text-white/60 text-base font-normal"
  18. >{{ t("common.breadcrumb.home") }}</nuxt-link
  19. >
  20. <span class="text-white/60 text-base font-normal px-2"> / </span>
  21. <nuxt-link
  22. v-if="product?.category"
  23. :to="`${homepagePath}/products?audiences=${product.meta?.audiences}`"
  24. class="text-white/60 text-base font-normal"
  25. >{{
  26. product.meta?.audiences === 0
  27. ? t("common.personal")
  28. : t("common.business")
  29. }}</nuxt-link
  30. >
  31. <span class="text-white/60 text-base font-normal px-2"> / </span>
  32. <nuxt-link
  33. v-if="product?.category"
  34. :to="`${homepagePath}/products?category=${encodeURIComponent(
  35. product.category
  36. )}&audiences=${product.meta?.audiences}`"
  37. class="text-white/60 text-base font-normal"
  38. >{{ product.category }}</nuxt-link
  39. >
  40. <span class="text-white/60 text-base font-normal px-2"> / </span>
  41. <span class="text-white text-base font-normal">{{
  42. product?.title || product?.name
  43. }}</span>
  44. </div>
  45. </div>
  46. <!-- 产品详情内容 -->
  47. <div
  48. v-if="product"
  49. class="max-w-full mb-12 md:mb-20 lg:mb-32 xl:px-2 lg:px-2 md:px-4 px-4"
  50. >
  51. <div class="max-w-screen-2xl mx-auto">
  52. <div class="grid grid-cols-1 lg:grid-cols-2 gap-8 lg:gap-16">
  53. <!-- 左侧产品图片 -->
  54. <div
  55. class="flex flex-col gap-6 lg:sticky lg:top-24 self-start select-none"
  56. >
  57. <!-- 主图展示 -->
  58. <div
  59. class="bg-zinc-900 rounded-lg box-border relative overflow-hidden group aspect-square"
  60. >
  61. <!-- 主图容器 - Swiper -->
  62. <Swiper
  63. :modules="[Navigation, Pagination, EffectFade, Thumbs]"
  64. :slides-per-view="1"
  65. :pagination="{
  66. clickable: true,
  67. dynamicBullets: true,
  68. dynamicMainBullets: 3,
  69. }"
  70. :navigation="true"
  71. :effect="'fade'"
  72. :fade-effect="{ crossFade: true }"
  73. :thumbs="{ swiper: thumbsSwiper }"
  74. class="w-full h-full product-swiper"
  75. @swiper="swiperInstance = $event"
  76. @slideChange="currentSlideIndex = $event.activeIndex"
  77. >
  78. <SwiperSlide
  79. v-for="(image, slideIndex) in [
  80. product.image,
  81. ...(product.gallery || []),
  82. ]"
  83. :key="slideIndex"
  84. >
  85. <div class="relative w-full h-full">
  86. <!-- 当前图片 -->
  87. <img
  88. :src="image"
  89. :alt="`${product.name} - ${t('products.image', {
  90. index: slideIndex + 1,
  91. })}`"
  92. class="w-full h-full object-contain rounded-lg transition-all duration-500"
  93. :class="{
  94. 'opacity-0': isSlideThumbnailLoading[slideIndex],
  95. 'opacity-100':
  96. !isSlideThumbnailLoading[slideIndex] &&
  97. !slideThumbnailErrors[slideIndex],
  98. }"
  99. @load="handleSlideImageLoad(slideIndex)"
  100. @error="handleSlideImageError(slideIndex)"
  101. />
  102. <!-- 加载状态 -->
  103. <div
  104. v-if="isSlideThumbnailLoading[slideIndex]"
  105. class="absolute inset-0 flex items-center justify-center bg-zinc-800/50 z-10"
  106. >
  107. <div
  108. class="animate-spin h-8 w-8 border-4 border-cyan-400 rounded-full border-t-transparent"
  109. ></div>
  110. </div>
  111. <!-- 错误提示 -->
  112. <div
  113. v-if="slideThumbnailErrors[slideIndex]"
  114. class="absolute inset-0 flex items-center justify-center bg-red-900/50 z-20"
  115. >
  116. <div class="flex flex-col items-center gap-2">
  117. <span class="text-white">{{
  118. t("products.imageLoadError")
  119. }}</span>
  120. <button
  121. @click.stop="retryLoadSlideImage(slideIndex)"
  122. class="px-4 py-2 bg-cyan-400 text-white rounded-lg hover:bg-cyan-600 transition-colors duration-300"
  123. >
  124. {{ t("products.retry") }}
  125. </button>
  126. </div>
  127. </div>
  128. </div>
  129. </SwiperSlide>
  130. </Swiper>
  131. <!-- 全局加载状态 - 仅在所有图片都未加载完成时显示 -->
  132. <div
  133. v-if="isInitialLoading"
  134. class="absolute inset-0 flex items-center justify-center bg-zinc-900/80 z-30"
  135. >
  136. <div
  137. class="animate-spin h-12 w-12 border-4 border-cyan-400 rounded-full border-t-transparent"
  138. ></div>
  139. </div>
  140. </div>
  141. <!-- 缩略图列表 - Swiper -->
  142. <div
  143. class="relative bg-zinc-900 rounded-lg py-6 px-8 overflow-hidden product-thumbnail-container"
  144. >
  145. <Swiper
  146. :modules="[Navigation, Thumbs, FreeMode]"
  147. :slides-per-view="'auto'"
  148. :space-between="12"
  149. :free-mode="true"
  150. :watch-slides-progress="true"
  151. :navigation="{
  152. nextEl: '.swiper-thumb-next',
  153. prevEl: '.swiper-thumb-prev',
  154. }"
  155. class="thumbs-swiper"
  156. @swiper="thumbsSwiper = $event"
  157. >
  158. <SwiperSlide
  159. v-for="(image, index) in [
  160. product.image,
  161. ...(product.gallery || []),
  162. ]"
  163. :key="index"
  164. class="!w-16 !h-16 md:!w-20 md:!h-20 !flex-shrink-0 cursor-pointer transition-all duration-300 relative"
  165. >
  166. <div
  167. class="w-full h-full rounded-lg overflow-hidden thumbnail-fixed-size"
  168. :class="{
  169. 'ring-2 ring-cyan-400 ring-offset-2 ring-offset-zinc-900':
  170. currentSlideIndex === index,
  171. 'hover:ring-1 hover:ring-cyan-400/50 hover:ring-offset-1 hover:ring-offset-zinc-900':
  172. currentSlideIndex !== index,
  173. 'opacity-50':
  174. isSlideThumbnailLoading[index] ||
  175. slideThumbnailErrors[index],
  176. }"
  177. >
  178. <!-- 缩略图加载状态 -->
  179. <div
  180. v-if="isSlideThumbnailLoading[index]"
  181. class="absolute inset-0 flex items-center justify-center bg-zinc-800/50 rounded-lg z-10"
  182. >
  183. <div
  184. class="animate-spin h-4 w-4 border-2 border-cyan-400 rounded-full border-t-transparent"
  185. ></div>
  186. </div>
  187. <!-- 缩略图遮罩 -->
  188. <div
  189. class="absolute inset-0 transition-all duration-300 rounded-lg"
  190. :class="{
  191. 'bg-black/30': currentSlideIndex === index,
  192. 'bg-black/0 hover:bg-black/20':
  193. currentSlideIndex !== index,
  194. }"
  195. ></div>
  196. <img
  197. :src="image"
  198. :alt="`${product.name} - ${t('products.image', {
  199. index: index + 1,
  200. })}`"
  201. class="w-full h-full object-cover transition-all duration-300 rounded-lg"
  202. :class="{
  203. 'opacity-0': isSlideThumbnailLoading[index],
  204. 'opacity-100':
  205. !isSlideThumbnailLoading[index] &&
  206. !slideThumbnailErrors[index],
  207. 'hover:scale-110': currentSlideIndex !== index,
  208. }"
  209. @load="handleSlideImageLoad(index)"
  210. @error="handleSlideImageError(index)"
  211. />
  212. <!-- 缩略图错误提示 -->
  213. <div
  214. v-if="slideThumbnailErrors[index]"
  215. class="absolute inset-0 flex items-center justify-center bg-red-900/50 rounded-lg"
  216. >
  217. <div class="flex flex-col items-center gap-1">
  218. <span class="text-white text-xs">{{
  219. t("products.error")
  220. }}</span>
  221. <button
  222. @click.stop="retryLoadSlideImage(index)"
  223. class="px-2 py-1 bg-cyan-400 text-white text-xs rounded hover:bg-cyan-600 transition-colors duration-300"
  224. >
  225. {{ t("products.retry") }}
  226. </button>
  227. </div>
  228. </div>
  229. </div>
  230. </SwiperSlide>
  231. </Swiper>
  232. <!-- 缩略图导航按钮 -->
  233. <button
  234. class="swiper-thumb-prev absolute top-1/2 left-2 z-10 w-8 h-8 flex items-center justify-center bg-black/50 hover:bg-cyan-400 rounded-full transform -translate-y-1/2 transition-all duration-300"
  235. >
  236. <svg
  237. xmlns="http://www.w3.org/2000/svg"
  238. class="h-5 w-5 text-white"
  239. fill="none"
  240. viewBox="0 0 24 24"
  241. stroke="currentColor"
  242. >
  243. <path
  244. stroke-linecap="round"
  245. stroke-linejoin="round"
  246. stroke-width="2"
  247. d="M15 19l-7-7 7-7"
  248. />
  249. </svg>
  250. </button>
  251. <button
  252. class="swiper-thumb-next absolute top-1/2 right-2 z-10 w-8 h-8 flex items-center justify-center bg-black/50 hover:bg-cyan-400 rounded-full transform -translate-y-1/2 transition-all duration-300"
  253. >
  254. <svg
  255. xmlns="http://www.w3.org/2000/svg"
  256. class="h-5 w-5 text-white"
  257. fill="none"
  258. viewBox="0 0 24 24"
  259. stroke="currentColor"
  260. >
  261. <path
  262. stroke-linecap="round"
  263. stroke-linejoin="round"
  264. stroke-width="2"
  265. d="M9 5l7 7-7 7"
  266. />
  267. </svg>
  268. </button>
  269. </div>
  270. </div>
  271. <!-- 右侧产品信息 -->
  272. <div class="flex flex-col gap-8">
  273. <!-- 产品名称 -->
  274. <div class="bg-zinc-900 rounded-lg p-2 md:p-6">
  275. <h1 class="text-white text-3xl font-medium mb-4">
  276. {{ product.title || product.name }}
  277. </h1>
  278. <div
  279. class="text-[#71717A] text-sm md:text-base leading-relaxed"
  280. >
  281. {{ product.summary }}
  282. </div>
  283. </div>
  284. <!-- 产品参数 -->
  285. <!-- <div
  286. class="bg-zinc-900 rounded-lg p-2 md:p-6 text-sm md:text-base"
  287. >
  288. <div class="grid grid-cols-1 gap-4">
  289. <div
  290. class="flex justify-between items-center gap-2 py-2 border-b border-zinc-800"
  291. >
  292. <span class="text-[#71717A] whitespace-nowrap">{{
  293. t("products.modelTitle")
  294. }}</span>
  295. <span class="text-white font-medium">{{
  296. product.model
  297. }}</span>
  298. </div>
  299. <div
  300. class="flex justify-between items-center gap-2 py-2 border-b border-zinc-800"
  301. >
  302. <span class="text-[#71717A] whitespace-nowrap">{{
  303. t("products.categoryTitle")
  304. }}</span>
  305. <span class="text-white font-medium"
  306. >{{ product.category
  307. }}<template v-if="product.tag">
  308. / {{ product.tag }}</template
  309. ></span
  310. >
  311. </div>
  312. <div
  313. v-if="product.tag"
  314. class="flex justify-between items-center gap-2 py-2 border-b border-zinc-800"
  315. >
  316. <span class="text-[#71717A] whitespace-nowrap">{{
  317. t("products.seriesTitle")
  318. }}</span>
  319. <span class="text-white font-medium">{{
  320. product.series?.join(" / ")
  321. }}</span>
  322. </div>
  323. <div
  324. class="flex justify-between items-center gap-2 py-2 border-b border-zinc-800"
  325. >
  326. <span class="text-[#71717A] whitespace-nowrap">{{
  327. t("products.usageTitle")
  328. }}</span>
  329. <span class="text-white font-medium">{{
  330. product.usage?.join(", ")
  331. }}</span>
  332. </div>
  333. <div
  334. v-if="product.capacities && product.capacities.length > 0"
  335. class="flex justify-between items-center py-2"
  336. >
  337. <span class="text-[#71717A]">{{
  338. t("products.capacitiesTitle")
  339. }}</span>
  340. <span class="text-white font-medium">{{
  341. product.capacities?.join(" / ")
  342. }}</span>
  343. </div>
  344. </div>
  345. </div> -->
  346. <!-- 产品描述 -->
  347. <!-- <div
  348. v-if="product.description"
  349. class="bg-zinc-900 rounded-lg p-2 md:p-6"
  350. >
  351. <h2 class="text-white text-xl font-medium mb-2 md:mb-6">
  352. {{ t("products.productDescription") }}
  353. </h2>
  354. <div
  355. class="text-[#71717A] leading-relaxed space-y-4 prose prose-invert max-w-none text-sm md:text-base"
  356. >
  357. {{ product.description }}
  358. </div>
  359. </div> -->
  360. <!-- 个人用户产品描述 -->
  361. <div
  362. v-if="product.meta?.audiences === 0"
  363. class="bg-zinc-900 rounded-lg p-2 md:p-6"
  364. >
  365. <div
  366. class="text-[#71717A] leading-relaxed space-y-4 prose prose-invert max-w-none text-sm md:text-base"
  367. >
  368. <ContentRenderer :value="product.content" />
  369. </div>
  370. </div>
  371. <!-- 相关产品 -->
  372. <div
  373. v-if="relatedProducts.length > 0"
  374. class="bg-zinc-900 rounded-lg p-2 md:p-6"
  375. >
  376. <h2 class="text-white text-xl font-medium mb-2 md:mb-6">
  377. {{ t("products.relatedProducts") }}
  378. </h2>
  379. <div class="grid grid-cols-2 md:grid-cols-3 gap-4">
  380. <nuxt-link
  381. v-for="relatedProduct in relatedProducts"
  382. :key="relatedProduct.id"
  383. :to="`${homepagePath}/products/${relatedProduct.id}`"
  384. class="group"
  385. >
  386. <div
  387. class="bg-zinc-800 rounded-lg p-4 transition-all duration-300 hover:bg-zinc-700"
  388. >
  389. <div
  390. class="aspect-square mb-4 overflow-hidden rounded-lg"
  391. >
  392. <img
  393. :src="relatedProduct.image"
  394. :alt="relatedProduct.title || relatedProduct.name"
  395. class="w-full h-full object-cover transition-transform duration-300 group-hover:scale-110"
  396. />
  397. </div>
  398. <h3
  399. class="text-white text-base md:text-lg font-medium mb-2 line-clamp-2"
  400. >
  401. {{ relatedProduct.title || relatedProduct.name }}
  402. </h3>
  403. <p class="text-[#71717A] text-sm line-clamp-2">
  404. {{ relatedProduct.summary }}
  405. </p>
  406. </div>
  407. </nuxt-link>
  408. </div>
  409. </div>
  410. </div>
  411. </div>
  412. <!-- 企业用户产品描述 -->
  413. <div
  414. v-if="product.meta?.audiences === 1"
  415. class="bg-zinc-900 rounded-lg p-2 md:p-6 mt-6 full-table-screen"
  416. >
  417. <div
  418. class="text-[#71717A] leading-relaxed space-y-4 prose prose-invert max-w-none text-sm md:text-base"
  419. >
  420. <ContentRenderer
  421. :value="product.content"
  422. />
  423. </div>
  424. </div>
  425. </div>
  426. </div>
  427. </div>
  428. </ErrorBoundary>
  429. </div>
  430. </template>
  431. <script setup lang="ts">
  432. /**
  433. * 产品详情页面
  434. * 展示产品主图、参数和描述
  435. */
  436. import { useErrorHandler } from "~/composables/useErrorHandler";
  437. import { useTableHighlight } from "~/composables/useTableHighlight";
  438. import { useRoute, useI18n, useAsyncData } from "#imports";
  439. import { queryCollection } from "#imports";
  440. import { ContentRenderer } from "#components";
  441. import { Swiper, SwiperSlide } from "swiper/vue";
  442. import {
  443. Navigation,
  444. Pagination,
  445. EffectFade,
  446. Thumbs,
  447. FreeMode,
  448. } from "swiper/modules";
  449. import type { Swiper as SwiperType } from "swiper";
  450. import "swiper/css";
  451. import "swiper/css/navigation";
  452. import "swiper/css/pagination";
  453. import "swiper/css/effect-fade";
  454. const { error, isLoading } = useErrorHandler();
  455. const { initTableHighlight } = useTableHighlight();
  456. const route = useRoute();
  457. const { locale, t } = useI18n();
  458. const id = route.params.id as string;
  459. const swiperInstance = ref<SwiperType | null>(null);
  460. const thumbsSwiper = ref<SwiperType | null>(null);
  461. // 图片状态
  462. const currentSlideIndex = ref(0);
  463. const isInitialLoading = ref(true); // 初始加载状态
  464. const isSlideThumbnailLoading = ref<boolean[]>([]);
  465. const slideThumbnailErrors = ref<boolean[]>([]);
  466. // 滚动跟随相关
  467. const scrollContainer = ref<HTMLElement | null>(null);
  468. const isSticky = ref(false);
  469. const homepagePath = computed(() => {
  470. return locale.value === "zh" ? "" : `/${locale.value}`;
  471. });
  472. interface Product {
  473. id: string;
  474. name: string;
  475. model: string;
  476. usage: string[];
  477. capacities: string[];
  478. category: string;
  479. categoryId: string;
  480. description: string;
  481. summary: string;
  482. image: string;
  483. gallery: string[];
  484. body: string;
  485. content?: any;
  486. tag?: string;
  487. series?: string[];
  488. meta?: {
  489. series?: string[];
  490. name?: string;
  491. title?: string;
  492. image?: string;
  493. summary?: string;
  494. audiences: number;
  495. };
  496. title?: string;
  497. }
  498. /**
  499. * 使用queryCollection获取产品数据
  500. */
  501. const { data: productContent } = await useAsyncData(
  502. `product-${id}`,
  503. async () => {
  504. try {
  505. // 使用queryCollection从content目录获取数据
  506. const content = await queryCollection("content")
  507. .where("path", "LIKE", `/products/${locale.value}/${id}`)
  508. .first();
  509. return content;
  510. } catch (err) {
  511. console.error("Error fetching product content:", err);
  512. error.value = new Error(t("products.loadError"));
  513. return null;
  514. }
  515. }
  516. );
  517. /**
  518. * 获取分类信息
  519. */
  520. const { data: categoryContent } = await useAsyncData(
  521. `category-${productContent.value?.meta?.categoryId}`,
  522. async () => {
  523. if (!productContent.value?.meta?.categoryId) return null;
  524. try {
  525. const content = await queryCollection("content")
  526. .where(
  527. "path",
  528. "LIKE",
  529. `/categories/${locale.value}/${productContent.value.meta?.categoryId}`
  530. )
  531. .first();
  532. return content;
  533. } catch (err) {
  534. console.error("Error fetching category:", err);
  535. return null;
  536. }
  537. },
  538. {
  539. immediate: !!productContent.value?.meta?.categoryId,
  540. }
  541. );
  542. /**
  543. * 使用计算属性解析产品数据
  544. */
  545. const product = computed<Product | any>(() => {
  546. if (!productContent.value) return null;
  547. // 提取产品数据
  548. const meta = productContent.value.meta || {};
  549. return {
  550. id: id,
  551. name: String(meta.name || productContent.value.title || ""),
  552. model: String(meta.model || ""),
  553. title: String(productContent.value.title || meta.name || ""),
  554. usage: Array.isArray(meta.usage) ? meta.usage : [],
  555. capacities: Array.isArray(meta.capacities) ? meta.capacities : [],
  556. category: categoryContent.value?.title || "",
  557. categoryId: meta.categoryId || "",
  558. description: productContent.value.description || "",
  559. summary: String(meta.summary || ""),
  560. image: String(meta.image || ""),
  561. gallery: Array.isArray(meta.gallery) ? meta.gallery : [],
  562. body: productContent.value.body || "",
  563. content: productContent.value,
  564. tag: meta.tag || "",
  565. series: Array.isArray(meta.series) ? meta.series : [],
  566. sn: meta.sn || "",
  567. meta: {
  568. series: Array.isArray(meta.series) ? meta.series : [],
  569. name: String(meta.name || ""),
  570. title: String(productContent.value.title || ""),
  571. image: String(meta.image || ""),
  572. summary: String(meta.summary || ""),
  573. audiences: categoryContent.value?.meta?.audiences || 0,
  574. sn: meta.sn || "",
  575. },
  576. };
  577. });
  578. // 初始化表格高亮功能
  579. initTableHighlight(computed(() => product.value?.model || ""));
  580. /**
  581. * 获取相关产品
  582. */
  583. const { data: relatedProductsContent } = await useAsyncData(
  584. `related-products-${id}`,
  585. async () => {
  586. try {
  587. // 获取产品列表
  588. const content = await queryCollection("content")
  589. .where("path", "LIKE", `/products/${locale.value}/%`)
  590. .all();
  591. console.log(content);
  592. const relatedProducts = content.filter((item: any) => {
  593. const meta = item.meta || {};
  594. return meta.sn === product.value.meta?.sn;
  595. });
  596. return relatedProducts;
  597. } catch (err) {
  598. console.error("Error fetching related products:", err);
  599. return [];
  600. }
  601. }
  602. );
  603. /**
  604. * 处理相关产品数据
  605. */
  606. const relatedProducts = computed(() => {
  607. if (!relatedProductsContent.value || !product.value) return [];
  608. // 获取当前产品的分类和系列
  609. const currentCategory = product.value.categoryId;
  610. const currentSeries = product.value.meta?.series || [];
  611. const currentProductId = id;
  612. return relatedProductsContent.value
  613. .filter((item: any) => {
  614. // 排除当前产品 - 多重检查确保排除
  615. if (item._path === `/products/${locale.value}/${id}`) return false;
  616. const meta = item.meta || {};
  617. if (meta.name === currentProductId) return false;
  618. const itemCategoryId = meta.categoryId || "";
  619. const itemSeries = Array.isArray(meta.series) ? meta.series : [];
  620. // 判断是否同类别或同系列
  621. const isSameCategory =
  622. currentCategory && itemCategoryId === currentCategory;
  623. const hasSameSeries =
  624. currentSeries.length > 0 &&
  625. itemSeries.some((series: string) => currentSeries.includes(series));
  626. // 返回同类别或同系列的产品
  627. return isSameCategory || hasSameSeries;
  628. })
  629. .map((item: any) => {
  630. const meta = item.meta || {};
  631. return {
  632. id: meta.name || "",
  633. name: meta.name || item.title || "",
  634. title: item.title || meta.name || "",
  635. image: meta.image || "",
  636. summary: meta.summary || "",
  637. category: meta.categoryId || "",
  638. series: Array.isArray(meta.series) ? meta.series : [],
  639. };
  640. })
  641. .slice(0, 6); // 最多显示6个相关产品
  642. });
  643. /**
  644. * 预加载下一张图片
  645. */
  646. function preloadNextImage(image: string) {
  647. currentSlideIndex.value =
  648. (currentSlideIndex.value + 1) % (product.value?.gallery?.length || 1);
  649. }
  650. /**
  651. * 处理图片加载完成
  652. */
  653. function handleSlideImageLoad(index: number) {
  654. isSlideThumbnailLoading.value[index] = false;
  655. slideThumbnailErrors.value[index] = false;
  656. // 检查是否所有图片都已加载
  657. const allImagesLoaded = isSlideThumbnailLoading.value.every(
  658. (status) => !status
  659. );
  660. if (allImagesLoaded) {
  661. isInitialLoading.value = false;
  662. }
  663. }
  664. /**
  665. * 处理图片加载错误
  666. */
  667. function handleSlideImageError(index: number) {
  668. isSlideThumbnailLoading.value[index] = false;
  669. slideThumbnailErrors.value[index] = true;
  670. }
  671. /**
  672. * 重试加载图片
  673. */
  674. function retryLoadSlideImage(index: number) {
  675. isSlideThumbnailLoading.value[index] = true;
  676. slideThumbnailErrors.value[index] = false;
  677. // 确定正确的图片URL
  678. const images = [product.value?.image, ...(product.value?.gallery || [])];
  679. const imageUrl = images[index];
  680. // 检查图片URL是否有效
  681. if (!imageUrl) {
  682. console.error("Invalid image URL:", index);
  683. slideThumbnailErrors.value[index] = true;
  684. isSlideThumbnailLoading.value[index] = false;
  685. return;
  686. }
  687. // 创建新的图片对象并设置超时
  688. const img = new Image();
  689. const timeoutId = setTimeout(() => {
  690. handleSlideImageError(index);
  691. }, 10000); // 10秒超时
  692. img.onload = () => {
  693. clearTimeout(timeoutId);
  694. handleSlideImageLoad(index);
  695. };
  696. img.onerror = (error) => {
  697. clearTimeout(timeoutId);
  698. console.error("Image load error:", { index, error });
  699. handleSlideImageError(index);
  700. };
  701. // 设置跨域属性
  702. img.crossOrigin = "anonymous";
  703. // 最后设置src以开始加载
  704. img.src = imageUrl;
  705. }
  706. // 页面加载时初始化状态
  707. onMounted(() => {
  708. // 初始化缩略图加载状态数组
  709. const galleryLength = (product.value?.gallery?.length || 0) + 1;
  710. isSlideThumbnailLoading.value = new Array(galleryLength).fill(true);
  711. slideThumbnailErrors.value = new Array(galleryLength).fill(false);
  712. // 设置初始加载状态
  713. isInitialLoading.value = true;
  714. // 预加载所有缩略图
  715. const images = [product.value?.image, ...(product.value?.gallery || [])];
  716. images.forEach((image, index) => {
  717. if (image) {
  718. const img = new Image();
  719. img.onload = () => handleSlideImageLoad(index);
  720. img.onerror = () => handleSlideImageError(index);
  721. img.src = image;
  722. }
  723. });
  724. // 添加滚动监听
  725. scrollContainer.value = document.querySelector(".max-w-screen-2xl");
  726. if (scrollContainer.value) {
  727. window.addEventListener("scroll", handleScroll, { passive: true });
  728. }
  729. });
  730. // 清理滚动监听
  731. onUnmounted(() => {
  732. if (scrollContainer.value) {
  733. window.removeEventListener("scroll", handleScroll);
  734. }
  735. });
  736. // 处理滚动事件
  737. function handleScroll() {
  738. if (!scrollContainer.value) return;
  739. const containerRect = scrollContainer.value.getBoundingClientRect();
  740. const scrollTop = window.scrollY || document.documentElement.scrollTop;
  741. // 当容器顶部距离视窗顶部小于100px时,启用sticky
  742. isSticky.value = containerRect.top < 100;
  743. }
  744. // SEO优化
  745. useHead(() => ({
  746. title: `${product.value?.name} - Hanye`,
  747. meta: [
  748. {
  749. name: "description",
  750. content: product.value?.description,
  751. },
  752. ],
  753. }));
  754. </script>
  755. <style lang="scss" scoped>
  756. /* 隐藏滚动条但保持滚动功能 */
  757. .scrollbar-hide {
  758. -ms-overflow-style: none; /* IE and Edge */
  759. scrollbar-width: none; /* Firefox */
  760. }
  761. .scrollbar-hide::-webkit-scrollbar {
  762. display: none; /* Chrome, Safari and Opera */
  763. }
  764. /* 图片过渡动画 */
  765. .main-image {
  766. transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  767. }
  768. /* 缩略图悬停效果 */
  769. .thumbnail-item {
  770. transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  771. }
  772. .thumbnail-item:hover {
  773. transform: translateY(-2px);
  774. }
  775. /* 缩略图选中效果 */
  776. .thumbnail-item.selected {
  777. transform: scale(1.05);
  778. box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
  779. 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  780. }
  781. /* 产品信息卡片效果 */
  782. .info-card {
  783. transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  784. }
  785. .info-card:hover {
  786. transform: translateY(-2px);
  787. box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
  788. 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  789. }
  790. /* 滚动跟随效果 */
  791. .lg\:sticky {
  792. position: sticky;
  793. top: 6rem; /* 96px */
  794. transition: all 0.3s ease;
  795. z-index: 10;
  796. max-height: calc(100vh - 6rem);
  797. overflow-y: auto;
  798. }
  799. @media (max-width: 1024px) {
  800. .lg\:sticky {
  801. position: relative;
  802. top: 0;
  803. max-height: none;
  804. }
  805. }
  806. /* Swiper 样式定制 */
  807. .product-swiper {
  808. :deep(.swiper-pagination-bullet) {
  809. background-color: white;
  810. opacity: 0.5;
  811. }
  812. :deep(.swiper-pagination-bullet-active) {
  813. opacity: 1;
  814. background-color: theme("colors.cyan.400");
  815. }
  816. :deep(.swiper-button-next),
  817. :deep(.swiper-button-prev) {
  818. color: theme("colors.cyan.500");
  819. background-color: rgba(0, 0, 0, 0.3);
  820. width: 36px;
  821. height: 36px;
  822. border-radius: 50%;
  823. &:after {
  824. font-size: 16px;
  825. font-weight: bold;
  826. }
  827. &:hover {
  828. background-color: theme("colors.cyan.500");
  829. color: white;
  830. }
  831. }
  832. :deep(.swiper-button-disabled) {
  833. opacity: 0.35;
  834. cursor: auto;
  835. pointer-events: none;
  836. }
  837. :deep(.swiper-slide) {
  838. display: flex;
  839. align-items: center;
  840. justify-content: center;
  841. }
  842. }
  843. /* 缩略图Swiper样式 */
  844. .thumbs-swiper {
  845. overflow: visible;
  846. padding: 0.25rem;
  847. min-height: 6rem;
  848. :deep(.swiper-wrapper) {
  849. align-items: center;
  850. display: flex;
  851. min-height: 6rem;
  852. }
  853. :deep(.swiper-slide) {
  854. width: auto;
  855. height: auto;
  856. opacity: 0.7;
  857. transition: all 0.3s ease;
  858. display: flex;
  859. align-items: center;
  860. justify-content: center;
  861. }
  862. :deep(.swiper-slide-thumb-active) {
  863. opacity: 1;
  864. transform: scale(1.05);
  865. z-index: 1;
  866. }
  867. }
  868. /* 自定义缩略图导航按钮 */
  869. .swiper-thumb-next,
  870. .swiper-thumb-prev {
  871. &:focus {
  872. outline: none;
  873. }
  874. &.swiper-button-disabled {
  875. opacity: 0.3;
  876. cursor: default;
  877. background-color: rgba(0, 0, 0, 0.2);
  878. &:hover {
  879. background-color: rgba(0, 0, 0, 0.2);
  880. }
  881. }
  882. }
  883. /* 响应式调整 */
  884. @media (max-width: 768px) {
  885. .thumbs-swiper {
  886. padding: 0;
  887. :deep(.swiper-slide) {
  888. margin-right: 8px;
  889. }
  890. }
  891. /* 确保缩略图容器在移动设备上有足够空间 */
  892. .product-thumbnail-container {
  893. padding: 1rem;
  894. .swiper-thumb-prev {
  895. left: 0.5rem;
  896. width: 2rem;
  897. height: 2rem;
  898. }
  899. .swiper-thumb-next {
  900. right: 0.5rem;
  901. width: 2rem;
  902. height: 2rem;
  903. }
  904. }
  905. }
  906. /* 解决不同分辨率下缩略图大小问题 */
  907. .thumbnail-fixed-size {
  908. width: 100%;
  909. height: 100%;
  910. aspect-ratio: 1 / 1;
  911. position: relative;
  912. }
  913. /* 表格样式和高亮效果 */
  914. :deep(.full-table-screen .prose table) {
  915. @apply border-collapse border border-zinc-700 rounded-lg overflow-hidden;
  916. }
  917. :deep(.full-table-screen .prose thead) {
  918. @apply bg-zinc-800;
  919. }
  920. :deep(.full-table-screen .prose th) {
  921. @apply px-6 py-3 text-left text-base font-medium text-zinc-300 uppercase tracking-wider border-b border-zinc-700;
  922. }
  923. :deep(.full-table-screen .prose tbody) {
  924. @apply bg-zinc-900 divide-y divide-zinc-700;
  925. }
  926. :deep(.full-table-screen .prose td) {
  927. @apply px-6 py-4 text-sm text-zinc-300 border-b border-zinc-700/50;
  928. }
  929. :deep(.full-table-screen .prose tr) {
  930. @apply transition-colors duration-200;
  931. }
  932. :deep(.full-table-screen .prose tr:hover:not(.highlighted-model-row)) {
  933. @apply bg-zinc-800/50;
  934. }
  935. /* 高亮当前型号对应的行 */
  936. :deep(.full-table-screen .prose tr.highlighted-model-row) {
  937. @apply bg-cyan-500/20 border border-cyan-400/50;
  938. }
  939. :deep(.full-table-screen .prose tr.highlighted-model-row td) {
  940. @apply text-cyan-400 font-medium;
  941. }
  942. /* 表格响应式处理 */
  943. @media (max-width: 640px) {
  944. :deep(.prose table) {
  945. font-size: 0.875rem;
  946. }
  947. :deep(.full-table-screen .prose th),
  948. :deep(.full-table-screen .prose td) {
  949. @apply px-3 py-2;
  950. }
  951. }
  952. /* 表格响应式容器 */
  953. :deep(.full-table-screen .prose) {
  954. /* 为包含表格的容器添加水平滚动 */
  955. & > *:has(table) {
  956. overflow-x: auto;
  957. -webkit-overflow-scrolling: touch;
  958. scrollbar-width: thin;
  959. scrollbar-color: theme("colors.cyan.400") theme("colors.zinc.800");
  960. }
  961. /* 自定义滚动条样式 */
  962. & > *:has(table)::-webkit-scrollbar {
  963. height: 8px;
  964. }
  965. & > *:has(table)::-webkit-scrollbar-track {
  966. background: theme("colors.zinc.800");
  967. border-radius: 4px;
  968. }
  969. & > *:has(table)::-webkit-scrollbar-thumb {
  970. background: theme("colors.cyan.400");
  971. border-radius: 4px;
  972. }
  973. & > *:has(table)::-webkit-scrollbar-thumb:hover {
  974. background: theme("colors.cyan.300");
  975. }
  976. }
  977. /* 小屏幕表格优化 */
  978. @media (max-width: 768px) {
  979. :deep(.full-table-screen .prose table) {
  980. min-width: 100%;
  981. white-space: nowrap;
  982. }
  983. :deep(.full-table-screen .prose th),
  984. :deep(.full-table-screen .prose td) {
  985. @apply px-2 py-2 text-xs;
  986. min-width: 100px; /* 确保最小宽度 */
  987. }
  988. /* 高亮列在小屏幕上更明显 */
  989. :deep(.full-table-screen .prose td.highlighted-model-column),
  990. :deep(.full-table-screen .prose th.highlighted-model-column) {
  991. @apply bg-cyan-500/30;
  992. position: sticky;
  993. z-index: 10;
  994. }
  995. :deep(.full-table-screen .prose td.highlighted-model-column)::before,
  996. :deep(.full-table-screen .prose th.highlighted-model-column)::before {
  997. width: 4px;
  998. }
  999. }
  1000. /* 超小屏幕处理 */
  1001. @media (max-width: 480px) {
  1002. :deep(.full-table-screen .prose th),
  1003. :deep(.full-table-screen .prose td) {
  1004. @apply px-1 py-1 text-xs;
  1005. min-width: 80px;
  1006. }
  1007. /* 为高亮列添加固定位置,确保始终可见 */
  1008. :deep(.full-table-screen .prose td.highlighted-model-column),
  1009. :deep(.full-table-screen .prose th.highlighted-model-column) {
  1010. position: sticky;
  1011. left: 0;
  1012. z-index: 20;
  1013. box-shadow: 2px 0 4px rgba(0, 0, 0, 0.1);
  1014. }
  1015. }
  1016. /* 列高亮基础样式 */
  1017. :deep(.full-table-screen .prose td.highlighted-model-column),
  1018. :deep(.full-table-screen .prose th.highlighted-model-column) {
  1019. @apply bg-cyan-500/20 text-cyan-400 font-medium;
  1020. position: relative;
  1021. }
  1022. :deep(.full-table-screen .prose td.highlighted-model-column)::before,
  1023. :deep(.full-table-screen .prose th.highlighted-model-column)::before {
  1024. content: "";
  1025. position: absolute;
  1026. left: 0;
  1027. top: 0;
  1028. bottom: 0;
  1029. width: 3px;
  1030. background-color: theme("colors.cyan.400");
  1031. }
  1032. /* 表格行悬停效果 */
  1033. :deep(.full-table-screen .prose tr:hover td:not(.highlighted-model-column)) {
  1034. @apply bg-zinc-800/30;
  1035. }
  1036. /* 表格响应式包装器样式 */
  1037. :deep(.table-responsive-wrapper) {
  1038. border-radius: 8px;
  1039. background: theme("colors.zinc.900");
  1040. padding: 1rem 0;
  1041. }
  1042. :deep(.scroll-indicator) {
  1043. animation: fadeInOut 3s ease-in-out infinite;
  1044. }
  1045. @keyframes fadeInOut {
  1046. 0%,
  1047. 100% {
  1048. opacity: 0.6;
  1049. }
  1050. 50% {
  1051. opacity: 1;
  1052. }
  1053. }
  1054. /* 优化表格在响应式包装器中的显示 */
  1055. :deep(.table-responsive-wrapper table) {
  1056. margin: 0;
  1057. border-radius: 0;
  1058. }
  1059. /* 滚动条增强 */
  1060. :deep(.table-responsive-wrapper::-webkit-scrollbar) {
  1061. height: 12px;
  1062. }
  1063. :deep(.table-responsive-wrapper::-webkit-scrollbar-track) {
  1064. background: theme("colors.zinc.800");
  1065. border-radius: 6px;
  1066. margin: 0 8px;
  1067. }
  1068. :deep(.table-responsive-wrapper::-webkit-scrollbar-thumb) {
  1069. background: linear-gradient(
  1070. 45deg,
  1071. theme("colors.cyan.500"),
  1072. theme("colors.cyan.400")
  1073. );
  1074. border-radius: 6px;
  1075. border: 2px solid theme("colors.zinc.800");
  1076. }
  1077. :deep(.table-responsive-wrapper::-webkit-scrollbar-thumb:hover) {
  1078. background: linear-gradient(
  1079. 45deg,
  1080. theme("colors.cyan.400"),
  1081. theme("colors.cyan.300")
  1082. );
  1083. }
  1084. /* 简化的表格响应式处理 - 覆盖之前的复杂样式 */
  1085. :deep(.full-table-screen .prose table) {
  1086. min-width: 700px !important;
  1087. width: 100% !important;
  1088. white-space: nowrap;
  1089. }
  1090. :deep(.full-table-screen .prose th),
  1091. :deep(.full-table-screen .prose td) {
  1092. white-space: nowrap !important;
  1093. min-width: 100px;
  1094. }
  1095. /* 移动设备优化 */
  1096. @media (max-width: 768px) {
  1097. :deep(.full-table-screen .prose table) {
  1098. min-width: 800px !important;
  1099. font-size: 0.875rem;
  1100. }
  1101. :deep(.full-table-screen .prose th),
  1102. :deep(.full-table-screen .prose td) {
  1103. min-width: 80px;
  1104. padding: 0.5rem 0.75rem !important;
  1105. }
  1106. }
  1107. @media (max-width: 480px) {
  1108. :deep(.full-table-screen .prose table) {
  1109. min-width: 600px !important;
  1110. }
  1111. :deep(.full-table-screen .prose th),
  1112. :deep(.full-table-screen .prose td) {
  1113. min-width: 90px !important;
  1114. padding: 0.25rem 0.375rem !important;
  1115. font-size: 0.75rem !important;
  1116. }
  1117. }
  1118. /* 优化单元格宽度 - 更合适的显示空间 */
  1119. :deep(.full-table-screen .prose table) {
  1120. min-width: 1000px !important; /* 增加整体表格宽度 */
  1121. }
  1122. :deep(.full-table-screen .prose th),
  1123. :deep(.full-table-screen .prose td) {
  1124. min-width: 150px !important; /* 增加单元格最小宽度 */
  1125. max-width: 300px; /* 设置最大宽度避免过宽 */
  1126. padding: 0.75rem 1rem !important; /* 增加内边距 */
  1127. }
  1128. /* 第一列(通常是标题列)给更多宽度 */
  1129. :deep(.full-table-screen .prose th:first-child),
  1130. :deep(.full-table-screen .prose td:first-child) {
  1131. min-width: 200px !important;
  1132. }
  1133. /* 针对不同屏幕尺寸的优化 */
  1134. @media (max-width: 1024px) {
  1135. :deep(.full-table-screen .prose table) {
  1136. min-width: 900px !important;
  1137. }
  1138. :deep(.full-table-screen .prose th),
  1139. :deep(.full-table-screen .prose td) {
  1140. min-width: 130px !important;
  1141. padding: 0.5rem 0.75rem !important;
  1142. }
  1143. }
  1144. @media (max-width: 768px) {
  1145. :deep(.full-table-screen .prose table) {
  1146. min-width: 800px !important;
  1147. }
  1148. :deep(.full-table-screen .prose th),
  1149. :deep(.full-table-screen .prose td) {
  1150. min-width: 120px !important;
  1151. padding: 0.5rem 0.5rem !important;
  1152. font-size: 0.875rem !important;
  1153. }
  1154. }
  1155. @media (max-width: 640px) {
  1156. :deep(.full-table-screen .prose table) {
  1157. min-width: 700px !important;
  1158. }
  1159. :deep(.full-table-screen .prose th),
  1160. :deep(.full-table-screen .prose td) {
  1161. min-width: 100px !important;
  1162. padding: 0.375rem 0.5rem !important;
  1163. font-size: 0.8rem !important;
  1164. }
  1165. }
  1166. @media (max-width: 480px) {
  1167. :deep(.full-table-screen .prose table) {
  1168. min-width: 600px !important;
  1169. }
  1170. :deep(.full-table-screen .prose th),
  1171. :deep(.full-table-screen .prose td) {
  1172. min-width: 90px !important;
  1173. padding: 0.25rem 0.375rem !important;
  1174. font-size: 0.75rem !important;
  1175. }
  1176. }
  1177. /* 单元格内容截断和悬停显示 */
  1178. :deep(.full-table-screen .prose th),
  1179. :deep(.full-table-screen .prose td) {
  1180. position: relative;
  1181. overflow: hidden !important;
  1182. text-overflow: ellipsis !important;
  1183. white-space: nowrap !important;
  1184. }
  1185. /* 悬停时显示完整内容 */
  1186. :deep(.full-table-screen .prose th:hover),
  1187. :deep(.full-table-screen .prose td:hover) {
  1188. overflow: visible !important;
  1189. white-space: normal !important;
  1190. z-index: 100;
  1191. background-color: theme("colors.zinc.800") !important;
  1192. box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
  1193. 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  1194. border-radius: 4px;
  1195. }
  1196. /* 高亮列的悬停效果 */
  1197. :deep(.full-table-screen .prose th.highlighted-model-column:hover),
  1198. :deep(.full-table-screen .prose td.highlighted-model-column:hover) {
  1199. background-color: theme("colors.cyan.600") !important;
  1200. color: white !important;
  1201. }
  1202. /* 确保悬停时的文本不会被遮挡 */
  1203. :deep(.full-table-screen .prose table) {
  1204. position: relative;
  1205. z-index: 1;
  1206. }
  1207. :deep(.full-table-screen .prose th:hover),
  1208. :deep(.full-table-screen .prose td:hover) {
  1209. position: relative;
  1210. z-index: 101;
  1211. }
  1212. /* 通用清除浮动工具类 */
  1213. .clearfix::before,
  1214. .clearfix::after {
  1215. content: "";
  1216. display: table;
  1217. }
  1218. .clearfix::after {
  1219. clear: both;
  1220. }
  1221. /* 简化的clearfix */
  1222. .clear-float::after {
  1223. content: "";
  1224. display: block;
  1225. clear: both;
  1226. }
  1227. /* 清除左浮动 */
  1228. .clear-left {
  1229. clear: left;
  1230. }
  1231. /* 清除右浮动 */
  1232. .clear-right {
  1233. clear: right;
  1234. }
  1235. /* 清除所有浮动 */
  1236. .clear-both {
  1237. clear: both;
  1238. }
  1239. </style>